{% extends "../master.html" %}
{% block hfm_css %}
<style type="text/css">
    .layui-form-label{
        width: 100px;
        background-color: rgba(247, 247, 247, 0.84);
    }
    .layui-input-block{
        margin-left: 100px;
        min-height: 30px;
    }
</style>
{% end %}
{% block page_content %}
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">资产管理</a>
        <a><cite>资产任务</cite></a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body layui-form layui-row layui-col-space10" id="projcet-query"
                    lay-filter="projcet-query">
                    <form class="layui-form layui-col-md4">
{#                        <!--{% raw xsrf_form_html() %}-->#}
                        <label class="layui-form-label">模糊查询</label>
                        <div class="layui-input-block">
                            <input type="text" name="condition" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </form>
                    <div class="layui-input-inline layui-show-xs-block TaskTable">
                        <button class="layui-btn" lay-submit="" lay-filter="sreach" data-type="reload">查询</button>
                    </div>
                </div>
                <xblock>
                    <div class="layui-card-header TaskTable">
                        <button class="layui-btn" onclick="xadmin.open('添加资产','/asset/add',850,500)">
                            <i class="layui-icon layui-icon-add-1"></i>添加资产
                        </button>
                        <button type="button" class="layui-btn" id="portscan" data-type="portscanchoice">
                            <i class="layui-icon layui-icon-refresh-3"></i>端口扫描
                        </button>
                    </div>
                </xblock>
                <!-- task table-->
                <div class="layui-card-body">
                    <table class="layui-table layui-form" id="task_table" lay-filter="option"></table>
                </div>
                <!--task table-->
            </div>
        </div>
    </div>
</div>
{% block sechfm_js %}
    <script type="text/html" id="barDemo">
      <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
      <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="start">删除</a>
    </script>
{% end %}

<script>
//var xsrf = $('input[name="_xsrf"]').val();
layui.use('table', function() {
    var table = layui.table;
    //方法级渲染
    table.render({
        elem: '#task_table'
        , url: "/task/list"
        , method: 'post'
        //,where: {'xsrf_token':xsrf}
        , cols: [[
            {checkbox: true, fixed: true,width:80}
            , {field: 'name', title: '资产名称', align: 'center', unresize: true}
            , {field:'hosts', title: '主机数量', align: 'center', unresize: true}
            , {field:'issearch', title: '是否探测', align: 'center', unresize: true}
            , {field: 'type', title: '类型', align: 'center', unresize: true}
            , {field: 'status', title: '状态', align: 'center', unresize: true}
            , {field: 'cycle', title: '周期',align: 'center', unresize: true}
            , {field: 'user', title: '操作人员',align: 'center', unresize: true}
            , {field: 'email', title: '邮箱',align: 'center', unresize: true}
            , {field: 'scannum', title: '扫描次数',align: 'center', unresize: true}
            , {field: 'nearscan', title: '最近扫描',align: 'center', unresize: true}
            ,{ title: '高级选项',fixed: 'right', align:'center', toolbar: '#barDemo', width: 120, unresize: true}
        ]]
        , id: 'testReload'
        , page: true
        , limit: 15
        , text: {none: '目前暂无数据'}
    });
    //头工具栏事件
    table.on('tool(option)', function(obj){
        var checkStatus = obj.data;
    });
    // 操作
    var $ = layui.$, active = {
        // 端口扫描
        portscanchoice: function(){ //获取选中数据
                var checkStatus = table.checkStatus('testReload')
                ,data = checkStatus.data;
                layer.msg('请选中要扫描的资产')
            }
        ,reload: function() {
            //执行重载
            //alert($('#id_task').val());
            table.reload('testReload', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {
                    condition: $('#condition').val()
                }
            });
            }
        };
        $('.TaskTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

})
</script>

{% end %}